function [a, P] = BlockPass(P,S,mode,k)

global num_players_r;
global num_players_b;

if(P{2}=='r')
    num_players = num_players_r;
    num_opponents = num_players_b;
else
    num_players = num_players_b;
    num_opponents = num_players_r;
end

B = S{1};
B_X=B{1}(1);
B_Y=B{1}(2);

Sk = S{1 + num_players + k};
Sk_X=Sk{1}(1);
Sk_Y=Sk{1}(2);

% copmute the midpoint between the ball and the player BEING blocked
Target_X = (B_X + Sk_X)/2;
Target_Y = (B_Y + Sk_Y)/2;

% move to the target position
[a, P] = GoToLocation(P,S,mode,Target_X, Target_Y);

end